package com.nali.spreader.dao.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.ibatis.SqlMapClientTemplate;
import org.springframework.stereotype.Repository;

import com.nali.spreader.dao.ICrudRegAddressDao;
import com.nali.spreader.data.RegAddress;
import com.nali.spreader.data.RegAddressExample;

@Repository
public class CrudRegAddressDao implements ICrudRegAddressDao {
    /**
     * This field was generated by Apache iBATIS ibator.
     * This field corresponds to the database table spreader.tb_reg_address
     *
     * @ibatorgenerated Wed Jun 06 17:41:16 CST 2012
     */
    @Autowired
    private SqlMapClientTemplate sqlMap;

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table spreader.tb_reg_address
     *
     * @ibatorgenerated Wed Jun 06 17:41:16 CST 2012
     */
    public CrudRegAddressDao() {
        super();
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table spreader.tb_reg_address
     *
     * @ibatorgenerated Wed Jun 06 17:41:16 CST 2012
     */
    public int countByExample(RegAddressExample example) {
        Integer count = (Integer)  getSqlMapClientTemplate().queryForObject("spreader_tb_reg_address.ibatorgenerated_countByExample", example);
        return count;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table spreader.tb_reg_address
     *
     * @ibatorgenerated Wed Jun 06 17:41:16 CST 2012
     */
    public int deleteByExample(RegAddressExample example) {
        int rows = getSqlMapClientTemplate().delete("spreader_tb_reg_address.ibatorgenerated_deleteByExample", example);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table spreader.tb_reg_address
     *
     * @ibatorgenerated Wed Jun 06 17:41:16 CST 2012
     */
    public int deleteByPrimaryKey(Long registerId) {
        RegAddress key = new RegAddress();
        key.setRegisterId(registerId);
        int rows = getSqlMapClientTemplate().delete("spreader_tb_reg_address.ibatorgenerated_deleteByPrimaryKey", key);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table spreader.tb_reg_address
     *
     * @ibatorgenerated Wed Jun 06 17:41:16 CST 2012
     */
    public void insert(RegAddress record) {
        getSqlMapClientTemplate().insert("spreader_tb_reg_address.ibatorgenerated_insert", record);
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table spreader.tb_reg_address
     *
     * @ibatorgenerated Wed Jun 06 17:41:16 CST 2012
     */
    public void insertSelective(RegAddress record) {
        getSqlMapClientTemplate().insert("spreader_tb_reg_address.ibatorgenerated_insertSelective", record);
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table spreader.tb_reg_address
     *
     * @ibatorgenerated Wed Jun 06 17:41:16 CST 2012
     */
    @SuppressWarnings("unchecked")
    public List<RegAddress> selectByExample(RegAddressExample example) {
        List<RegAddress> list = getSqlMapClientTemplate().queryForList("spreader_tb_reg_address.ibatorgenerated_selectByExample", example);
        return list;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table spreader.tb_reg_address
     *
     * @ibatorgenerated Wed Jun 06 17:41:16 CST 2012
     */
    public RegAddress selectByPrimaryKey(Long registerId) {
        RegAddress key = new RegAddress();
        key.setRegisterId(registerId);
        RegAddress record = (RegAddress) getSqlMapClientTemplate().queryForObject("spreader_tb_reg_address.ibatorgenerated_selectByPrimaryKey", key);
        return record;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table spreader.tb_reg_address
     *
     * @ibatorgenerated Wed Jun 06 17:41:16 CST 2012
     */
    public int updateByExampleSelective(RegAddress record, RegAddressExample example) {
        UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
        int rows = getSqlMapClientTemplate().update("spreader_tb_reg_address.ibatorgenerated_updateByExampleSelective", parms);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table spreader.tb_reg_address
     *
     * @ibatorgenerated Wed Jun 06 17:41:16 CST 2012
     */
    public int updateByExample(RegAddress record, RegAddressExample example) {
        UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
        int rows = getSqlMapClientTemplate().update("spreader_tb_reg_address.ibatorgenerated_updateByExample", parms);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table spreader.tb_reg_address
     *
     * @ibatorgenerated Wed Jun 06 17:41:16 CST 2012
     */
    public int updateByPrimaryKeySelective(RegAddress record) {
        int rows = getSqlMapClientTemplate().update("spreader_tb_reg_address.ibatorgenerated_updateByPrimaryKeySelective", record);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table spreader.tb_reg_address
     *
     * @ibatorgenerated Wed Jun 06 17:41:16 CST 2012
     */
    public int updateByPrimaryKey(RegAddress record) {
        int rows = getSqlMapClientTemplate().update("spreader_tb_reg_address.ibatorgenerated_updateByPrimaryKey", record);
        return rows;
    }

    /**
     * This method was generated by Apache iBATIS ibator.
     * This method corresponds to the database table spreader.tb_reg_address
     *
     * @ibatorgenerated Wed Jun 06 17:41:16 CST 2012
     */
    public SqlMapClientTemplate getSqlMapClientTemplate() {
        return sqlMap;
    }

    /**
     * This class was generated by Apache iBATIS ibator.
     * This class corresponds to the database table spreader.tb_reg_address
     *
     * @ibatorgenerated Wed Jun 06 17:41:16 CST 2012
     */
    private static class UpdateByExampleParms extends RegAddressExample {
        private Object record;

        public UpdateByExampleParms(Object record, RegAddressExample example) {
            super(example);
            this.record = record;
        }

        public Object getRecord() {
            return record;
        }
    }
}